<?php
/**
 * Created by PhpStorm.
 * User: yangfan
 * Date: 2019/11/7
 * Time: 11:54 AM
 */

namespace App\BO\OrderStatus\State;

use App\BO\OrderStatus\Events\OrderCommentedEvent;
use App\BO\OrderStatus\OrderStateContext;

class WaitingCommentState extends AOrderState
{
    protected $desc = '待评价';

    /**
     * @return bool
     */
    public function hasServiceInfo()
    {
        return true;
    }

    public function comment()
    {
        // 评价完成，将订单关闭
        $this->stateContext->setOrderState(OrderStateContext::getInstance(CommentedState::class));
        // 订单设置为已经评论
        $this->orderStateModifyStore->toCommented();

        event(new OrderCommentedEvent($this->stateContext->getOrder()));
    }
}
